//
//  StuUserViewController.m
//  test
//
//  Created by 朱圳 on 2018/1/13.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "StuUserViewController.h"
#import "StuUserCell.h"
#import "UserModel.h"
#import "UserManager.h"


@interface StuUserViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *list;
@property(nonatomic,strong)UserModel *model;

@end

@implementation StuUserViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"个人信息";
    self.model = [UserManager me];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"U.plist" ofType:nil];
    self.list =[NSMutableArray arrayWithContentsOfFile:path];
    [self.view addSubview:self.tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.list.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"stuUserCell";
     StuUserCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell == nil) {
        cell = [[StuUserCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.nameLabel.text = self.list[indexPath.row][@"name"];
    cell.tximg.image = [UIImage imageNamed:self.list[indexPath.row][@"img"]];
    cell.dataText.enabled = NO;
    
    if (indexPath.row == 0) {
        cell.dataText.text = self.model.name;
    }
    if (indexPath.row == 1) {
        if ([self.model.sex isEqualToString:@"1"]) {
             cell.dataText.text = @"女";
        }else{
             cell.dataText.text = @"男";
        }
    }
    if (indexPath.row == 2) {
        cell.dataText.text = self.model.phone;
    }
    if (indexPath.row == 3) {
        cell.dataText.text = self.model.jname;
    }
    if (indexPath.row == 4) {
        cell.dataText.text = self.model.pname;
    }
    if (indexPath.row == 5) {
        cell.dataText.text = self.model.college;
    }
    if (indexPath.row == 6) {
        cell.dataText.text = self.model.jieshu;
        cell.dataText.enabled = NO;
    }
    if (indexPath.row == 7) {
        cell.dataText.text = self.model.address;
    }
    if (indexPath.row == 8) {
        cell.dataText.text = self.model.math;
    }
    if (indexPath.row == 9) {
        cell.dataText.text = self.model.english;
    }
    if (indexPath.row == 10) {
        cell.dataText.text = self.model.goal;
    }
    if (indexPath.row == 11) {
        cell.dataText.text = [Utility getDateStringWithTimeStr:self.model.Applytime];
    }
    if (indexPath.row == 12) {
        cell.dataText.text = self.model.QQ;
    }
    if (indexPath.row == 13) {
        cell.dataText.text = self.model.Winxin;
    }
    if (indexPath.row == 14) {
        cell.dataText.text = self.model.BirthDay;
    }
    if (indexPath.row == 15) {
        cell.dataText.text = self.model.dadphone;
    }
    if (indexPath.row == 16) {
        cell.dataText.text = self.model.mumphone;
    }
    if (indexPath.row == 17) {
        cell.dataText.text = self.model.BuyCourse;
    }
    if (indexPath.row == 18) {
        cell.dataText.text = self.model.Baiduyun;
    }
    if (indexPath.row == 19) {
        cell.dataText.text = self.model.Vyan;
    }
    if (indexPath.row == 20) {
        cell.dataText.text = self.model.Classes;
    }
    return cell;
}
/** 区foot视图 */
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footer=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 120)];
    
    UILabel *lb1=[[UILabel alloc]init];
    lb1.text=@"邮寄书籍";
    lb1.textAlignment=NSTextAlignmentCenter;
    
    [footer addSubview:lb1];
    [lb1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(footer);
        make.top.equalTo(footer.mas_top).offset(0);
        make.height.mas_equalTo(30);
    }];
    
    UITextView * text = [[UITextView alloc]init];
    text.text=self.model.mailbook;
    text.layer.borderWidth = 1;
    text.layer.borderColor = [UIColor orangeColor].CGColor;
    [footer addSubview:text];
    [text mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.top.mas_equalTo(lb1.mas_bottom) setOffset:5];
        [make.left.mas_equalTo(footer.mas_left) setOffset:10];
        [make.right.mas_equalTo(footer.mas_right) setOffset:-10];
        make.size.height.mas_equalTo(80);
    }];
   
        text.userInteractionEnabled=NO;
    return footer;
}
/*******设置高度解决Button点击没效果*******/
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return 120;
}
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, -30, ScreenWidth, ScreenHeight+30)style:UITableViewStyleGrouped];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = [UIColor whiteColor];
        [_tableView registerClass:[StuUserCell class] forCellReuseIdentifier:@"stuUserCell"];
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}
@end
